﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Lilium.Web.Mvc.Validation
{
	/// <summary>
	/// Контекст, используемый для валидаци действий.
	/// </summary>
	public class ValidateActionContext: ActionContext
	{
		/// <summary>
		/// Этод конструктор используется для генерации контекста дествия на основе контекста фильтра.
		/// </summary>
		/// <param name="filterContext"></param>
		public ValidateActionContext(ActionExecutingContext actionExecutingContext)
			: base(actionExecutingContext)
		{
			if (actionExecutingContext == null) throw new ArgumentNullException("actionExecutingContext");

			m_ActionParameters = new Dictionary<string, object>(actionExecutingContext.ActionParameters);
		}

		public ValidateActionContext(Lilium.IServiceProvider serviceProvider, IDictionary<string, object> actionParameters)
			: base(serviceProvider)
		{
			if (actionParameters == null) throw new ArgumentNullException("actionParameters");

			m_ActionParameters = new Dictionary<string, object>(actionParameters);
		}

		#region public IModelErrors ModelErrors

		private readonly IModelErrors m_ModelErrors =  new ModelErrors();

		public IModelErrors ModelErrors
		{
			get
			{
				return m_ModelErrors;
			}
		}
		
		#endregion

		#region public IDictionary<string, object> ActionParameters

		private readonly IDictionary<string, object> m_ActionParameters;

		public IDictionary<string, object> ActionParameters
		{
			get
			{
				return m_ActionParameters;
			}
		}

		#endregion
	}
}